home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revista CD Expert 32
/
CD Expert nº 32.iso
/
Army Men TiS
/
data1.cab
/
Required_Files
/
rules
/
holdflag_ai.txt
< prev
next >
Wrap
Text File
|
1999-10-08
|
4KB
|
120 lines
// this gets loaded on the host if the @1 army is AI controlled
// @1 = color of army to do AI for, @2-@4 = other colors
macro holdflag_ai_macro 4
{
// This variable holds the current action for @1
// 0 means no action, 1 means follow black flag, 2 means get powerups, 3 means hold the flag
variable @1Action 0
if startup1 then
triggerdelay 1000 @1ChooseNewAction,
triggerdelay 2000 @1RegularOrders
if @1ChooseNewAction then
setvar @1Action 0,
trigger @1CheckIfHoldFlag,
trigger @1CheckIfFlagUnheld,
trigger @1ChoseAction
// if it's time to choose a new action but we are currently owning the hill then
// we should always stay on the hill
if @1CheckIfHoldFlag testvar hasitem @1sarge1 blackflag1 = 1 then
trigger @1ReturnToBase
// if it's time to choose a new action and the hill is not owned then head straight for it
if @1CheckIfFlagUnheld testvar hasitem @2sarge1 blackflag1 = 0 and hasitem @3sarge1 blackflag1 = 0 and hasitem @4sarge1 blackflag1 = 0 then
trigger @1FollowFlag
// if @1 has no current action then pick an action
// ideally we would base this on how well armed we are
if @1ChooseAction testvar @1Action = 0 then
trigger @1PickRandomAction,
triggerdelay 1000 @1ChooseAction
if @1PickRandomAction then random
trigger @1FollowFlag,
trigger @1GetPowerUps
// these events setup the @1Action variable and do the actions
if @1FollowFlag then
setvar @1Action 1,
order @1sarge1 follow blackflag1 inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 follow blackflag1 inmode attack,
order @1 group 3 follow blackflag1 inmode attack,
trigger @1StartTimeOut
if @1GetPowerUps then
setvar @1Action 2,
order @1sarge1 follow blackflag1 inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 follow blackflag1 inmode attack,
order @1 group 3 follow blackflag1 inmode attack,
trigger @1StartTimeOut
if @1ReturnToBase then
setvar @1Action 3,
order @1sarge1 goto @1base inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 goto @1base inmode defend,
order @1 group 3 goto @1base inmode defend,
trigger @1StartTimeOut
if @1HoldFlag then
setvar @1Action 4,
order @1sarge1 goto @1base inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 goto @1base inmode defend,
order @1 group 3 goto @1base inmode defend,
trigger @1StartTimeOut
// these events chose a new action if we get on the hill
if pickedup blackflag1 by @1sarge1 then
trigger @1ReturnToBase
if pickedup blackflag1 by @2sarge1 then
trigger @1FollowFlag
if pickedup blackflag1 by @3sarge1 then
trigger @1FollowFlag
if pickedup blackflag1 by @4sarge1 then
trigger @1FollowFlag
if padon @1base testvar hasitem @1sarge1 blackflag1 = 1 then
trigger @1HoldFlag
// these events choose new actions if a sarge is killed
if killed @1sarge1 then
triggerdelay 5000 @1GetPowerups
// these are the standing order regardless of what mode sarge is in
if @1RegularOrders then
setaimode @1 group 4 defend,
setaimode @1 group 5 defend,
order @1 group 7 goto @1base inmode defend,
triggerdelay 5000 @1RegularOrders
// timeout code - if mode has not changed for a while then change it
variable @1TimeOutVar 0
variable @1LastTimeOutVar 1
if @1StartTimeOut then
addvar @1TimeOutVar 1,
triggerdelay 120000 @1CheckTimeOut
if @1CheckTimeOut testvar @1TimeOutVar = @1LastTimeOutVar then
trigger @1ChooseNewAction
if @1CheckTimeOut testvar @1TimeOutVar <> @1LastTimeOutVar then
addvar @1LastTimeOutVar 1
}